/*   1:    */ package com.atomikos.beans;
/*   2:    */ 
/*   3:    */ import java.lang.reflect.Constructor;
/*   4:    */ import java.util.HashMap;
/*   5:    */ import java.util.Map;
/*   6:    */ 
/*   7:    */ public final class PrimitiveClasses
/*   8:    */ {
/*   9: 40 */   private static Map map_ = new HashMap();
/*  10: 43 */   private static Map numericMap_ = new HashMap();
/*  11:    */   
/*  12:    */   static
/*  13:    */   {
/*  14: 51 */     map_.put(Boolean.TYPE, Boolean.class);
/*  15: 52 */     map_.put(Character.TYPE, Character.class);
/*  16: 53 */     map_.put(Short.TYPE, Short.class);
/*  17: 54 */     map_.put(Integer.TYPE, Integer.class);
/*  18: 55 */     map_.put(Long.TYPE, Long.class);
/*  19: 56 */     map_.put(Float.TYPE, Float.class);
/*  20: 57 */     map_.put(Double.TYPE, Double.class);
/*  21: 58 */     map_.put(Byte.TYPE, Byte.class);
/*  22: 59 */     map_.put(Void.TYPE, Void.class);
/*  23:    */     
/*  24: 61 */     numericMap_.put(Short.class, new Boolean(false));
/*  25: 62 */     numericMap_.put(Integer.class, new Boolean(false));
/*  26: 63 */     numericMap_.put(Long.class, new Boolean(false));
/*  27: 64 */     numericMap_.put(Float.class, new Boolean(true));
/*  28: 65 */     numericMap_.put(Double.class, new Boolean(true));
/*  29:    */   }
/*  30:    */   
/*  31:    */   public static boolean isNumericClass(Class clazz)
/*  32:    */   {
/*  33: 78 */     return numericMap_.containsKey(clazz);
/*  34:    */   }
/*  35:    */   
/*  36:    */   public static boolean isDecimalClass(Class clazz)
/*  37:    */   {
/*  38: 89 */     boolean ret = false;
/*  39:    */     
/*  40: 91 */     Boolean value = (Boolean)numericMap_.get(clazz);
/*  41: 92 */     if (value != null) {
/*  42: 92 */       ret = value.booleanValue();
/*  43:    */     }
/*  44: 94 */     return ret;
/*  45:    */   }
/*  46:    */   
/*  47:    */   public static Class getWrapperClass(Class primitiveClass)
/*  48:    */   {
/*  49:105 */     return (Class)map_.get(primitiveClass);
/*  50:    */   }
/*  51:    */   
/*  52:    */   public static Object createWrapperObject(String val, Class primitiveClass)
/*  53:    */     throws ClassNotPrimitiveException
/*  54:    */   {
/*  55:122 */     Object ret = null;
/*  56:    */     
/*  57:124 */     Class[] args = new Class[1];
/*  58:125 */     args[0] = String.class;
/*  59:126 */     Class wrapperClass = getWrapperClass(primitiveClass);
/*  60:127 */     if (wrapperClass == null) {
/*  61:128 */       throw new ClassNotPrimitiveException(primitiveClass.getName());
/*  62:    */     }
/*  63:    */     try
/*  64:    */     {
/*  65:131 */       Constructor c = wrapperClass.getConstructor(args);
/*  66:132 */       Object[] initArgs = new Object[1];
/*  67:133 */       initArgs[0] = val;
/*  68:134 */       if (c != null) {
/*  69:135 */         ret = c.newInstance(initArgs);
/*  70:    */       }
/*  71:    */     }
/*  72:    */     catch (Exception e)
/*  73:    */     {
/*  74:139 */       throw new RuntimeException(e.getMessage());
/*  75:    */     }
/*  76:142 */     return ret;
/*  77:    */   }
/*  78:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\atomikos-util\3.7.0\atomikos-util-3.7.0.jar
 * Qualified Name:     com.atomikos.beans.PrimitiveClasses
 * JD-Core Version:    0.7.0.1
 */